package ringbuffer;
import com.lmax.disruptor.EventTranslatorOneArg;
import com.lmax.disruptor.RingBuffer;

public class MsgEventProducerWithTranslator {
	private final RingBuffer<MsgEvent> ringBuffer;

	public MsgEventProducerWithTranslator(RingBuffer<MsgEvent> ringBuffer) {
		this.ringBuffer = ringBuffer;
	}

	private static final EventTranslatorOneArg<MsgEvent, String> TRANSLATOR = new EventTranslatorOneArg<MsgEvent, String>() {
		public void translateTo(MsgEvent event, long sequence, String msg) {
			event.set(msg);
		}
	};

	public void onData(String msg) {
		ringBuffer.publishEvent(TRANSLATOR, msg);
	}
}